﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace HYSoft.Web
{
    public partial class Register : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void agree_Click(object sender, EventArgs e)
        {
            Model.user usermodel = new Model.user();
            usermodel.loginname = this.TextBox1.Value.Trim();
            usermodel.passwd=this.TextBox2.Value.Trim();
            usermodel.unit=this.TextBox4.Value.Trim();
            usermodel.addr=this.TextBox5.Value.Trim();
            usermodel.postcode=this.TextBox6.Value.Trim();
            string[] Province = Request.Form.GetValues("selProvince1");
            string prov = Province[selProvince1.SelectedIndex].Split('|')[1];

            string[] City = Request.Form.GetValues("selCity1");
            string citys = City[selCity1.SelectedIndex].Split('|')[1];
            string[] District = Request.Form.GetValues("selDistrict1");
            string dis = District[selDistrict1.SelectedIndex].Split('|')[1];
            string area = prov + citys + dis;
            usermodel.m_area_name = area;
            usermodel.m_area_id = area;
            usermodel.name=this.TextBox9.Value.Trim();
            usermodel.mobile=this.TextBox10.Value.Trim();
            usermodel.telephone=this.TextBox11.Value.Trim();
            usermodel.fax=this.TextBox12.Value.Trim();
            usermodel.email=this.TextBox13.Value.Trim();
            usermodel.type=Int32.Parse( this.DropDownList1.SelectedValue);
            usermodel.intvalue1=1;
            usermodel.intvalue2=0;
            if (new BLL.user().Existsusername(usermodel))
            {
                Response.Write("<script>alert('该用户已经被注册，请选择其他用户名进行注册！');history.back();</script>");
            }
            else
            {
                if (this.DropDownList1.SelectedValue == "1")
                    new BLL.user().Add(usermodel);
                else{
                    usermodel.intvalue1=0;
                    new BLL.user().Add(usermodel);
                }
                 Response.Write("<script>alert('注册用户成功！请等待管理员审批！');window.location = 'index.aspx';</script>");
            }
        }
    }
}